package com.future.taskdemo.task;

import org.future.task.core.annotate.AutoBond;
import org.future.task.core.flow.FlowEntry;
import org.future.task.core.handler.Connection;
import org.future.task.core.handler.HandClient;
import org.future.task.core.handler.RunnableTask;
import org.future.task.redis.cluster.CEntry;
import org.future.task.redis.cluster.CType;
import org.future.task.redis.cluster.CmdClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TaskHandler extends RunnableTask<FlowEntry> {

    Logger log = LoggerFactory.getLogger(TaskHandler.class);

    @AutoBond
    private Connection mutiRedisConnection;

//    @AutoBond
//    private CmdClient cmdClient;

    @Override
    public void execute(FlowEntry flowEntry) throws InterruptedException {
        Object data = flowEntry.getData();
        CEntry cEntry = new CEntry(CType.DEL);
        cEntry.setBigKey(String.valueOf(data)).setVal(String.valueOf(data));
//        Thread.sleep(10);
//        System.out.println("hhh");
//        cmdClient.putToRedis(cEntry);
        HandClient.cli("MM").sendData(data);
//        log.info("ceshi:{}", data);
    }

    @Override
    public void tryException(FlowEntry flowEntry, Exception e) {
        e.printStackTrace();
    }
}
